"use client"; import { GameListRep } from "@/api/home"; import { userInfoApi } from "@/api/login"; import { Wallet } from "@/api/user"; import { ChannelType, getWithDrawApi, WithDrawParams, WithDrawType } from "@/api/withdraw"; import { clearWallet } from "@/app/[locale]/(navbar)/withdraw/actions"; import Box from "@/components/Box"; import ButtonOwn from "@/components/ButtonOwn"; import Empty from "@/components/Empty"; import MobileField from "@/components/Fields/MobileField"; import TipsModal, { ModalProps } from "@/components/TipsModal"; import useGame from "@/hooks/useGame"; import { useSystemStore } from "@/stores/useSystemStore"; import { useUserInfoStore } from "@/stores/useUserInfoStore"; import { useWalletStore } from "@/stores/useWalletStore"; import { isEmail } from "@/utils"; import { flatPoint, percentage } from "@/utils/methods"; import { ActionSheet, Button, Form, Input, ProgressBar, Toast } from "antd-mobile"; import { FormInstance } from "antd-mobile/es/components/form"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { FC, useRef, useState } from "react"; import { Swiper, SwiperSlide } from "swiper/react"; import "./page.scss"; interface Props { channels: WithDrawType[]; wallet: Wallet; playlist?: GameListRep[]; } export enum ChannelEnum { CPF = 1, Email, Phone, CNPJ, } type FieldValueType = { account_no: string; channel_id: (typeof ChannelEnum)[keyof typeof ChannelEnum]; type: number; code_phone?: string; }; interface MobileFieldProps { value?: FieldValueType; onChange?: (value: FieldValueType) => void; actions: Array; } const PixField: FC = (props) => { const { actions, value = { account_no: "", channel_id: actions[0].id, type: actions[0].type }, onChange, } = props; let [visible, setVisible] = useState(false); const t = useTranslations("WithdrawPage"); let [prefix, setPrefix] = useState(actions[0]); let [placeholder, setPlaceholder] = useState("000.000.000-00"); const onAction = (item: any) => { setPrefix(item); onRealValueChange(""); if (item.type === ChannelEnum.CPF) { setPlaceholder("000.000.000-00"); return; } if (item.type === ChannelEnum.CNPJ) { setPlaceholder("00.000.000.0000-00"); return; } if (item.type === ChannelEnum.Phone) { setPlaceholder("11 dígitos"); return; } if (item.type === ChannelEnum.Email) { setPlaceholder("Email"); return; } }; const onRealValueChange = (value: string) => { console.log(`🚀🚀🚀🚀🚀-> in WithdrawWidget.tsx on 80`, value); // console.log('prefix', prefix) let account_no = value; if (prefix.type === 1) { account_no = value .replace(/[^0-9]/g, "") .replace(/[\-]/g, "") .slice(0, 11); // console.log('account_no', value.replace(/\D/g, '')) // account_no = account_no.slice(0,3) } if (onChange) { onChange({ account_no, channel_id: prefix.id, type: prefix.type }); // console.log('value', props.value) } }; const mobileChange = (values: any) => { if (onChange) { onChange({ account_no: values.realValue, channel_id: prefix.id, type: prefix.type, code_phone: values.preValue, }); } }; return ( <>
setVisible(true)} className={"mr-[0.1rem] flex flex-shrink-0"}> {prefix.text}
{prefix.type === ChannelEnum.Phone ? ( ) : ( )}
setVisible(false)} /> ); }; const WithdrawWidget: FC = (props) => { const t = useTranslations(); const { channels, wallet } = props; const { getGameUrl } = useGame(); const isStrictMode = useSystemStore((state) => state.identity_verify.withdraw === 1); const score = useWalletStore((state) => state.score)!; // 彩金 const withdrawRef = useRef(null); const bounsModalRef = useRef(null); // 积分 const scoreRef = useRef(null); // 未完成游戏 const gameModelRef = useRef(null); const game = useRef(null); // 表单 const formRef = useRef(null); // 是否能提现 const [activeWallet, setActiveWallet] = useState(channels[0]); const walletAction = activeWallet && activeWallet.channels?.map((item) => ({ text: ChannelEnum[item.type], key: item.id, ...item, })); const userInfo = useUserInfoStore((state) => state.userInfo); const initParams = { channel: "", amount: "", passport: userInfo.passport, user_name: userInfo.user_name, }; const paramsTarget = useRef(null); const AmountValidator = (rules: any, value: string) => { const num = +value; if (num > activeWallet.max_amount) { return Promise.reject( new Error(t("WithdrawPage.amountReg", { max: activeWallet.max_amount })) ); } if (score && num > score) { return Promise.reject(new Error(t("WithdrawPage.amountMaxReg"))); } return Promise.resolve(); }; const ChannelValidator = (rules: any, value: FieldValueType) => { if (!value.account_no) return Promise.reject(new Error(t("WithdrawPage.channel"))); if (value.type === ChannelEnum.CPF) { return value.account_no.length !== 11 ? Promise.reject(new Error(t("WithdrawPage.cpfReg"))) : Promise.resolve(); } if (value.type === ChannelEnum.CNPJ) { return value.account_no.length !== 14 ? Promise.reject(new Error(t("WithdrawPage.cnpjReg"))) : Promise.resolve(); } if (value.type === ChannelEnum.Email) { return isEmail(value.account_no) ? Promise.resolve() : Promise.reject(new Error(t("WithdrawPage.EmailReg"))); } if (value.type === ChannelEnum.Phone) { return value.account_no.length < 10 ? Promise.reject(new Error(t("WithdrawPage.phoneReg"))) : Promise.resolve(); } return Promise.resolve(); }; const onFinish = async (value: any) => { const params = { ...value, ...value.channel, amount: +value.amount }; // 如果是电话号码,拼接区号 if (params.code_phone) { params.account_no = `${params.code_phone}${params.account_no}`; } delete params.channel; const { data } = await userInfoApi(); // 如果有未完成游戏 if (data.play_list && data.play_list.length > 0) { game.current = data.play_list[0]; gameModelRef.current?.onOpen(); return; } // 如果彩金 || 彩金打码量不为0 if ( flatPoint(wallet.target_point_rollover - wallet.current_point_rollover) > 0 || (wallet.point || 0) > 0 ) { paramsTarget.current = params; bounsModalRef.current?.onOpen(); return; } extractHandler(params); }; const extractHandler = async (params: WithDrawParams) => { const withResult = await getWithDrawApi(params).catch((error) => { Toast.show(t(`code.${error.data.code}`)); }); if (withResult && withResult.code === 200) { Toast.show(t("code.200")); } await clearWallet(); }; const goGame = () => { const current = game.current; getGameUrl(current!, { id: current?.id + "" }); }; if (!activeWallet) return ; return ( <>
{activeWallet.name}
{/*
*/} {/* {channels.map((item) => {*/} {/* return (*/} {/* */} {/* {*/} {/* formRef.current?.resetFields();*/} {/* setActiveWallet(item);*/} {/* }}*/} {/* >*/} {/* {item.name}*/} {/*

*/} {/*
*/} {/* );*/} {/* })}*/} {/*
*/} {channels?.map((item, index) => (

{ formRef.current?.resetFields(); setActiveWallet(item); }} > {item.name}

))}

{t("WithdrawPage.Certifique")}

{t("WithdrawPage.keyTips")}

  • {t("WithdrawPage.rulesRange", { min: activeWallet.min_amount, max: activeWallet.max_amount, })}
  • {t("WithdrawPage.rulesToll", { toll: activeWallet.fee_rate, })}
{/* form */}
{t("WithdrawPage.Saque")}} > {isStrictMode ? ( <> ) : null}

{t("WithdrawPage.Tipo")}

{activeWallet.channels?.length && ( )}

{t("WithdrawPage.Vincule")}

{t("WithdrawPage.Montante")} (BRL):

  • {t("WithdrawPage.SaqueDisponivel")}{" "} {/* 如果当前现金打码量等于当前目标打码量 则 可以提现, 如果当前打码量=== 100% 则可以提现 */} {flatPoint( wallet.target_score_rollover - wallet.current_score_rollover ) === 0 || percentage( wallet.current_score_rollover, wallet.target_score_rollover ) >= 100 ? wallet.score : 0} BRL scoreRef.current?.onOpen()} >
  • {t("WithdrawPage.Valor")} {flatPoint( wallet.target_score_rollover - wallet.current_score_rollover ) === 0 || percentage( wallet.current_score_rollover, wallet.target_score_rollover ) >= 100 ? flatPoint((wallet.score || 0) + wallet.point) : 0} BRL withdrawRef.current?.onOpen()} >
  • {t("WithdrawPage.Para")},{" "} {t("WithdrawPage.Aposte")}
{/*本金*/} SACAR {t("WithdrawPage.scoreTitle")} } ref={scoreRef} >
  • {t("WithdrawPage.scoreTips")} {wallet.score}
  • {percentage( wallet.current_score_rollover, wallet.target_score_rollover )} %
    {t("WithdrawPage.pointBet")} {flatPoint( wallet.target_score_rollover - wallet.current_score_rollover )}
{/*彩金*/} {t("WithdrawPage.pointTitle")} } ref={withdrawRef} >
  • {t("WithdrawPage.pointTips")} {wallet.point}
  • {percentage( wallet.current_point_rollover, wallet.target_point_rollover )} %
    {t("WithdrawPage.pointBet")} {flatPoint( wallet.target_point_rollover - wallet.current_point_rollover )}
{/*含有彩金提现拦截*/} Retirar bem sucedido, seu dinheiro de prémio será limpo. Você tem certeza? } ref={bounsModalRef} >
  • {t("WithdrawPage.pointTips")} {wallet.point}
  • {percentage( wallet.current_point_rollover, wallet.target_point_rollover )} %
    {t("WithdrawPage.pointBet")} {flatPoint( wallet.target_point_rollover - wallet.current_point_rollover )}
{/* 提现拦截 */}

Atualmente, existem jogos de bônus inacabados que não podem iniciar saques.

); }; export default WithdrawWidget;